fix: fixes TEST_PRINTF() expansion error #691 #692
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes TEST_PRINTF() expansion error when no variadic arguments are passed.
I want to use TEST_PRINTF(), so I set
-D UNITY_INCLUDE_PRINT_FORMATTED
in my compilation flags.I got a compile time error:
The compiler reports an error after
__VA_ARGS__
.The problem is that
TEST_PRINTF()
is defined as a variadic macro, but I'm not passing any variadic argument. Sure, i may useTEST_MESSAGE()
instead, but if someone wants to useTEST_PRINTF()
it should work.I read this document: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
and I modified the macro
TEST_PRINTF()
in the following way:So everything works: